#ifndef _HAL_FLASH_H_
#define _HAL_FLASH_H_

#include <stdio.h>
#include <stdint.h>
#include "stm32l5xx_hal.h"


#define BOOT_START_ADDR         FLASH_BASE
#define BOOT_SIZE               (FLASH_PAGE_SIZE * 17)
#define CONFIG_START_ADDR       (BOOT_START_ADDR + BOOT_SIZE)
#define CONFIG_SIZE             (FLASH_PAGE_SIZE * 1)
#define APP_START_ADDR          (CONFIG_START_ADDR + CONFIG_SIZE)
#define APP_SIZE                (FLASH_PAGE_SIZE * 110)
#define APP_BAK_START_ADDR      (APP_START_ADDR + APP_SIZE)
#define APP_BAK_SIZE            (FLASH_PAGE_SIZE * 110)
#define JSON_DATA_START_ADDR    (APP_BAK_START_ADDR + APP_BAK_SIZE)
#define JSON_DATA_SIZE          (FLASH_PAGE_SIZE * 8)

//#define CONFIG_START_ADDR       (JSON_DATA_START_ADDR + JSON_DATA_SIZE)
//#define CONFIG_SIZE             (FLASH_PAGE_SIZE * 1)


int32_t hal_flash_erase(uint32_t erase_addr, uint32_t size);
int32_t hal_flash_read(uint8_t *p_data, uint32_t read_addr, uint32_t size);
int32_t hal_flash_write(uint8_t *p_data, uint32_t write_addr, uint32_t size);



#endif
